POV-Ray : Newsgroups : povray.advanced-users : Isosurface question : Re: Isosurface question Server Time
28 Jul 2024 18:12:59 EDT (-0400)
  Re: Isosurface question  
From: Mike Williams
Date: 20 Jul 2004 22:02:50
Message: <GqstUBAz6c$AFwBa@econym.demon.co.uk>
Wasn't it Andrew C on Mozilla who wrote:
>Isosurfaces... wonderful things, aren't they?
>
>At the present moment, I have one that's going increadibly slowly. 
>That's probably because of the huge max_gradiant required to draw it. 
>But it surely doesn't help that I have to explain the function I want 
>POV-Ray to draw in a very inefficient way...
>
>  * * *
>
>Suppose I have a macro like this:
>
>#macro Fn1(x, y, z)
>   #declare A = sin(x) * cos(y) * tan(z);
>   #declare B = sqrt(x*y / z);
>   #declare C = exp(log(x)*y - z);
>
>   (A*B - C)*(tan(A+B)-log(C))
>#end
>
>Now, suppose I wanted to draw an isosurface of that. (I completely made 
>up the function - I imagine it's not very interesting to look at!) The 
>only way I can think of to draw it is something like this:
>
>#declare Fn1 =
>{
>   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
>(tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z)) )
>}
>
>Notice how A, B and C have to be calculated *TWICE*...
>
>Is there any way round this??
>
>Andrew @ home.

I don't think so.

If you write

#declare A = function {sin(x) * cos(y) * tan(z)}
#declare B = function {sqrt(x*y / z)}
#declare C = function {exp(log(x)*y - z)}
   
#declare Fn1 = function {(A(x,y,z)*B(x,y,z) - C(x,y,z))
              *(tan(A(x,y,z)+B(x,y,z))-log(C(x,y,z)))}

I believe that POV still calculates A B and C twice. It certainly takes
quite a bit longer to render the surface when it's written this way than
when you write

#declare Fn1 = function {
   ( (sin(x) * cos(y) * tan(z))*sqrt(x*y / z) - exp(log(x)*y - z) ) * 
(tan(sin(x) * cos(y) * tan(z) + sqrt(x*y / z)) - log(exp(log(x)*y - z))
)}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.